<template>
	
</template>

<script>
	// import { Toast, getStorage, redirectTo, setStorage } from '@/utils/uni-api'


	
    export default {
		methods:{
			kfByApp(){
				// 首先需要通过 uni.requireNativePlugin("ModuleName") 获取 module
				var testModule = uni.requireNativePlugin("MeiQia-ChatPlugin");
				testModule.initChatViewManger();
				 
				let _clientInfo = this.getMemberInfo(); 
				if( _clientInfo ) {
					testModule.setClientInfo({
					    clientInfo:_clientInfo,
					    override: true
					 });
				}
				
				testModule.showMeiQiaChatView(); 
			},
			kfByH5(){
				(function(m, ei, q, i, a, j, s) {
					console.log('123')
				        m[i] = m[i] || function() {
				            (m[i].a = m[i].a || []).push(arguments)
				        };
				        j = ei.createElement(q),
				            s = ei.getElementsByTagName(q)[0];
				        j.async = true;
				        j.charset = 'UTF-8';
				        j.src = 'https://static.meiqia.com/dist/meiqia.js';
				        s.parentNode.insertBefore(j, s);
				})(window, document, 'script', '_MEIQIA');
				console.log('321')
				_MEIQIA('entId', '646c47d47148019c31ac6420ad776905');
				let _clientInfo = this.getMemberInfo(); 
				if( _clientInfo ){
					_MEIQIA('metadata', _clientInfo);
				}
				console.log('124')
				// 初始化成功后调用美洽 showPanel
				_MEIQIA('withoutBtn');
				_MEIQIA('allSet', function(){
				});
				_MEIQIA('showPanel');
			},
			getMemberInfo(){
				//先读storage里面的信息
				let _memberInfo = {}||uni.getStorage('memberInfo');
				if( _memberInfo ) {
					 return {
				          address:"用户名：" + _memberInfo.username,
				          weixin:"银行名称：" + _memberInfo.bank_name,
				          name: _memberInfo.real_name,
						  email:"昵称：" + _memberInfo.nickname,
						  qq:"身份证号：" + _memberInfo.id_card,
						  tel:_memberInfo.mobile,
						  weibo:"银行卡号："+ _memberInfo.bank_num
					}
				}
				return [];
			}
		},
        onLoad() {
			// #ifdef H5
			   console.log('走的h5页面');
			   this.kfByH5();
			// #endif
			// APP： 打成app包的时候
			// #ifdef APP-PLUS
				console.log('走的app页面');
				this.kfByApp();
			// #endif
		
			  
			  
			  // setTimeout(()=>{
				 //  // #ifdef H5
				 //     console.log('走的h5页面');
				 //     this.kfByH5();
				 //  // #endif
				 //  // APP： 打成app包的时候
				 //  // #ifdef APP-PLUS
				 //  	console.log('走的app页面');
				 //  	this.kfByApp();
				 //  // #endif
			  // },100)
         }
    }
</script>

<style>
	
	
</style>